'''
Created on 2012-10-23

@author: infear
'''
import re,util

def convert(_file):
    block=[]
    block.append('<html><head><title>test<title></head><body>')
    title=True
    f=open(_file,'r')
    for b in util.block(f):
        b=re.sub(r'\*(.+?)\*',r'<em>\1</em>',b)
        if title:
            block.append('<h1>') 
            block.append(b)
            block.append('</h1>')
            title=False
        else:
            block.append('<p>')
            block.append(b)
            block.append('</p>')
    block.append('</body></html>')
    yield ''.join(block)